<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="../style/journal.css" type="text/css" />
<style type="text/css"><!--
.googleadsense {
	margin: 2px;
	padding: 0px;
//--></style><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-65008-1";
urchinTracker();
</script><title>Win32下的进程模块</title>
</head>
<body>
<a href="index.html">Journal</a>(2005) | <a href="../blog/"><b>Blog</b></a>(2006) | <a href="http://www.fayland.org/cgi-bin/random_link.pl">RandomLink</a> | <a href="AboutFayland.html">WhoAmI</a> | <a href="LiveBookmark.html">LiveBookmark</a> | <a href="http://www.fayland.org/">HomePage</a>
<p><&lt;Previous: <a href="ReadRSS.html">RSS阅读设置</a>&nbsp;&nbsp;>>Next: <a href="ReferSite.html">ReferSite</a></p>
<h1>Win32下的进程模块</h1>
<div class='content'>
<p>Category: <a href='Modules.html'>Modules</a> &nbsp; Keywords: <b>Win32::Process</b></p>我的任务很简单，启动一个程序(c:\a.exe)，然后过1分种终止进程，然后再启动，如此循环/loop.<p />

Win32::Process我没用过，也是第一次用，其中什么子进程之类的也不太懂。详细的请查阅perldoc Win32::Process.<br />
如下是我的代码，给需要完成相似任务的朋友做参考：<br />
<pre>
use Win32::Process;

while (1) {
    my ($ProcessObj, $exitcode);
    Win32::Process::Create($ProcessObj,
        "c:\\a.exe",
        "",
        0,
        NORMAL_PRIORITY_CLASS,
        ".")|| die ErrorReport();

    $ProcessObj->GetExitCode( $exitcode );
    sleep 60;
    my $pid = $ProcessObj->GetProcessID();
    Win32::Process::KillProcess($pid, $exitcode);
    sleep 1;
}
</pre></div>
<p><&lt;Previous: <a href="ReadRSS.html">RSS阅读设置</a>&nbsp;&nbsp;>>Next: <a href="ReferSite.html">ReferSite</a></p>
<p><strong>Options:</strong> <a href='http://del.icio.us/post?title=Win32%E4%B8%8B%E7%9A%84%E8%BF%9B%E7%A8%8B%E6%A8%A1%E5%9D%97&url=http://www.fayland.org/journal/Win32Process.html'>+Del.icio.us</a></p>
<strong>Related items</strong>
<ul><li><a href='ReadRSS.html'>RSS阅读设置</a> < <span class='digit'>2004-10-30 19:26:40</span> ></li><li><a href='RSS.html'>给网页增加RSS</a> < <span class='digit'>2005-01-12 18:22:53</span> ></li><li><a href='050925_RSS.html'>RSS date</a> < <span class='digit'>2005-09-25 14:56:11</span> ></li></ul>
Created on <span class="digit">2004-10-30 19:29:19</span>, Last modified on <span class="digit">2004-11-11 00:27:57</span><br />
Copyright 2004-2005 All Rights Reserved. Powered by <a href="Eplanet.html">Eplanet</a> && <a href='http://catalyst.perl.org'>Catalyst</a> 5.62.
</body>
</html>